var pageNo = 1; //当前页数
var loading = false; //状态标记
var getPage = function() {
		$.ajax({
			type: "get",
			url: ctx + "/weixin/getUserTask?flag=list&pageNo=" + pageNo + "&pageSize=20&openid="+param().openid,
			success: function(result) {
				if(result.flag == "now"){
					location.href="task.html?id="+result.results[0].id;
					return;
				}
				result = result.results;
				if(result.length == 0 ){
					$(".weui_panel_bd").html("无数据！");
				}
				if (result.length < 21) {
					$(document.body).destroyInfinite();
					$(".weui-infinite-scroll").hide();
				}
				var tpl = $("#tpl").text();
				var html = juicer(tpl, {
					list: result
				});
				$(".weui_panel_bd").append(html);
				loading = false;
				pageNo++;
			},
			error: function(err) {
				console.error(err);
				$.alert("系统异常！");
			}
		});
	}
//加载列表
$(document.body).infinite().on("infinite", function() {
	if (loading) return;
	loading = true;
	getPage();
});
//
var appendOpenid = function(data){
	return "task.html?state=add&task_id=" + data + "&openid="+param().openid;
}
juicer.register('appendOpenid', appendOpenid);
$(function() {
	$(document.body).trigger("infinite");
});